package com.laomuji.android.mvvm.demo.firebase

import android.Manifest
import com.laomuji.android.mvvm.base.BaseActivity
import com.laomuji.android.mvvm.base.BaseActivityViewModel
import com.laomuji.android.mvvm.databinding.ActivityFirebaseBinding
import com.laomuji.android.mvvm.utils.MyLog
import com.laomuji.android.mvvm.utils.ResourceUtil
import com.laomuji.android.mvvm.utils.firebase.FirebaseTest
import com.laomuji.android.mvvm.utils.permission.PermissionCallback
import com.laomuji.android.mvvm.utils.permission.PermissionUtil

/**
 * Firebase 例子
 * @author laomuji666
 * @since 2024/4/25
 */
class FirebaseActivity:BaseActivity<ActivityFirebaseBinding,BaseActivityViewModel>() {
    override fun initView() {
        viewBinding.root.setPadding(0, ResourceUtil.getStatusBarHeight(), 0, 0)
        viewBinding.btEvent.setOnClickListener {
            FirebaseTest.testFirebaseAnalytics()
        }
        viewBinding.btCrash.setOnClickListener {
            FirebaseTest.testCrashlytics()
        }
        viewBinding.btNotifyPermission.setOnClickListener {
            PermissionUtil.requestPermissions(object : PermissionCallback(){
                override fun onGranted() {
                    FirebaseTest.getPushTokenFCM {
                        MyLog.iCustom("tag_firebase","push_token: $it")
                    }
                }
            },Manifest.permission.POST_NOTIFICATIONS)
        }
    }

    override fun initData() {

    }
}